package com.wqr.customer;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.netflix.ribbon.RibbonClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author LTX
 */
@SpringBootApplication
@RestController
@RibbonClients(
        @RibbonClient(value = "hello-server")
)
public class CustomerApplication {

    public static void main(String[] args) {
        SpringApplication.run(CustomerApplication.class, args);
    }

    /**
     * @LoadBalanced 轮询 配合多个提供者使用
     *
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate template(){
        return new RestTemplate();
    }

    /**
     * ZoneAvoidanceRule
     * 区域规避策略（默认策略）
     * AbstractLoadBalancerRule
     * 抽象策略，策略的模板
     * RoundRobinRule
     * 轮询策略
     * BestAvailableRule
     * 最小调用数
     * RandomRule
     * 随机数策路
     * RetryRule
     * 重试策略
     * WeightedResponseTimeRule
     * 权重策略
     * AvailabilityFilteringRule
     * 线性抽样策略
     * @return
     */
//    @Bean
//    public IRule ribbonRule(){
//        //自定义规则 新建一个IRule
//
//        //随机数策略
//        return new RandomRule();
//    }

}
